#define  _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
int main()
{
	int k = 0;
	int n = 0;
	char arr[100] = { 0 };
	int dx, xx, sz;
	scanf("%d", &n);
	for (k = 0; k < n; k++)
	{
		dx = 0; xx = 0; sz = 0;
		scanf("%s", arr);
		int i, j;
		if (strlen(arr) < 8)
		{
			printf("NO\n");
			continue;
		}
		if (arr[0] >= '0' && arr[0] <= '9')
		{
			printf("NO\n");
			continue;
		}
		for (i = 0; arr[i] != '\0'; i++)
		{

			if (arr[i] >= '0' && arr[i] <= '9' || arr[i] >= 'A' && arr[i] <= 'Z' || arr[i] >= 'a' && arr[i] <= 'z')
				;
			else
			{
				goto add;

			}
		}
		for (i = 0; arr[i] != '\0'; i++)
		{
			if (arr[i] >= '0' && arr[i] <= '9')
				sz++;
			else if (arr[i] >= 'A' && arr[i] <= 'Z')
				dx++;
			else if (arr[i] >= 'a' && arr[i] <= 'z')
				xx++;
		}
		if (sz == 0 && dx == 0 || sz == 0 && xx == 0 || dx == 0 && sz == 0)
			goto add;

		printf("YES\n");
		continue;

	add: {
		printf("NO\n");
		continue;
		}



	}





}